#include <stdio.h>
#include <stdlib.h>

#define NUM 8
int main(void)
{
    int **p = (int **)malloc(sizeof(int) * NUM);
    int i;
    int *tmp;

    // 二级指针数组-赋值
    for (tmp = (int *)p, i = 0; i < NUM; i++, tmp++)
    {
        *tmp = i;
    }

    // 二级指针数组-遍历
    for (tmp = (int *)p, i = 0; i < NUM; i++, tmp++)
    {
        printf("%d\n", *tmp);
    }

    // 遍历地址
    for(i=0;i<NUM;i++)
    {
        printf("p[%d] address=%p\n",i,p+i);
    }

    return 0;
}

/* 运行结果
0
1
2
3
4
5
6
7

p[0] address=0x55dc94d3e2a0
p[1] address=0x55dc94d3e2a8
p[2] address=0x55dc94d3e2b0
p[3] address=0x55dc94d3e2b8
p[4] address=0x55dc94d3e2c0
p[5] address=0x55dc94d3e2c8
p[6] address=0x55dc94d3e2d0
p[7] address=0x55dc94d3e2d8
 */